import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { jbSupplierListData } from '/@/api/quotation/jbSupplier';

const { t } = useI18n('quotation.jbSupplier');

const modalProps = {
  title: t('供应商基本信息表选择'),
};

const searchForm: FormProps = {
  baseColProps: { md: 8, lg: 6 },
  labelWidth: 90,
  schemas: [
    {
      label: t('供应商名称'),
      field: 'supplierName',
      component: 'Input',
    },
    {
      label: t('供应商联系人姓名'),
      field: 'contactsName',
      component: 'Input',
    },
    {
      label: t('供应商联系人电话'),
      field: 'contactsMobile',
      component: 'Input',
    },
    {
      label: t('供应商地址'),
      field: 'supplierAddress',
      component: 'Input',
    },
    {
      label: t('供应商法人'),
      field: 'legalPerson',
      component: 'Input',
    },
    {
      label: t('供应商LOGO路径'),
      field: 'supplierLogo',
      component: 'Input',
    },
    {
      label: t('统一信用代码'),
      field: 'creditCode',
      component: 'Input',
    },
    {
      label: t('报价单显示的简称'),
      field: 'shortName',
      component: 'Input',
    },
    {
      label: t('简称的拼音首字母，用于快速搜索'),
      field: 'pinyinCode',
      component: 'Input',
    },
    {
      label: t('状态'),
      field: 'status',
      component: 'Select',
      componentProps: {
        dictType: 'sys_search_status',
        allowClear: true,
      },
    },
    {
      label: t('创建者姓名'),
      field: 'createByName',
      component: 'Input',
    },
    {
      label: t('更新者姓名'),
      field: 'updateByName',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('供应商名称'),
    dataIndex: 'supplierName',
    key: 'a.supplier_name',
    sorter: true,
    width: 230,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('供应商联系人姓名'),
    dataIndex: 'contactsName',
    key: 'a.contacts_name',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('供应商联系人电话'),
    dataIndex: 'contactsMobile',
    key: 'a.contacts_mobile',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('供应商地址'),
    dataIndex: 'supplierAddress',
    key: 'a.supplier_address',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('供应商法人'),
    dataIndex: 'legalPerson',
    key: 'a.legal_person',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('供应商LOGO路径'),
    dataIndex: 'supplierLogo',
    key: 'a.supplier_logo',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('统一信用代码'),
    dataIndex: 'creditCode',
    key: 'a.credit_code',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('报价单显示的简称'),
    dataIndex: 'shortName',
    key: 'a.short_name',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('简称的拼音首字母，用于快速搜索'),
    dataIndex: 'pinyinCode',
    key: 'a.pinyin_code',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('更新时间'),
    dataIndex: 'updateDate',
    key: 'a.update_date',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('状态'),
    dataIndex: 'status',
    key: 'a.status',
    sorter: true,
    width: 130,
    align: 'center',
    dictType: 'sys_search_status',
  },
  {
    title: t('创建者姓名'),
    dataIndex: 'createByName',
    key: 'a.create_by_name',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('更新者姓名'),
    dataIndex: 'updateByName',
    key: 'a.update_by_name',
    sorter: true,
    width: 130,
    align: 'left',
  },
];

const tableProps: BasicTableProps = {
  api: jbSupplierListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'supplierId',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'supplierId',
  itemName: 'supplierId',
  isShowCode: false,
};
